package dao;

import java.sql.ResultSet;
import java.util.ArrayList;
import modal.InventoryItemModal;


public class InventoryDAO extends BaseDAO{

	public void addProduct(int ProductID, int UserID) throws Exception {
		String query = "INSERT INTO `inventory`(`ProductID`, `UserID`) VALUES ('" +ProductID+ "','" + UserID+"')";
		execQuery(query);
	}

	public ArrayList<InventoryItemModal> getProductwithUserId(int UserID) throws Exception {
		String query = "SELECT * FROM `inventory` WHERE `UserID` = "+ UserID +"";
		ResultSet rs =execQuery(query);
		ArrayList <InventoryItemModal> product=new ArrayList<InventoryItemModal>();
		while(rs.next()){
			InventoryItemModal pr=new InventoryItemModal(rs.getInt("ProductID"),rs.getInt("UserID"));
			product.add(pr);
		} 
		return product; 
	}
}
